package fr.paulmasson.jfreex;

import java.util.ArrayList;
import java.util.List;

import fr.paulmasson.jfreex.db.DbManager;
import fr.paulmasson.jfreex.db.bo.BoChannel;
import fr.paulmasson.jfreex.db.bo.BoProvider;
import fr.paulmasson.jfreex.db.dao.Dao;
import fr.paulmasson.jfreex.db.dao.DaoChannel;
import fr.paulmasson.jfreex.db.dao.DaoChannelInfo;
import fr.paulmasson.jfreex.db.dao.DaoProvider;

public class Test {

	public static void main(String[] args) {
		DbManager.startDbServer();
		DaoChannelInfo.setup();
		DaoChannelInfo.toFormattedString();
		
		DaoProvider.setup();
		DaoProvider.toFormattedString();
		
		
		
		BoProvider prov = new BoProvider();
		BoChannel channel = new BoChannel();
		channel.setName("chaine de test");
		channel.setProvider(prov);
		prov.setName("test");
		prov.setChannelUrl("");
		prov.setChannelUrlMirror("");
		List<BoChannel> c = new ArrayList<BoChannel>();
		c.add(channel);
		prov.setChannels(c);
		
		
		DbManager.saveEntity(prov);
		
		DaoProvider.toFormattedString();
		
		DaoChannel.toFormattedString();
		
		DaoProvider.retrieveChannel(DaoProvider.getBoProvider(1), true);
		DaoProvider.toFormattedString();
		DaoChannel.toFormattedString();
		
		
//		List<Object> list = DbManager.get("from BoChannel where provider.id=1");
//		Dao.printTable(list);
		
		DbManager.stopDbServer();
	}
	
}
